﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace H.Core
{
    public static class Check
    {
        public static void NotEmpty(Guid value, string parameterName)
        {
            if (value == Guid.Empty)
            {
                RaiseArgumentEmptyException(parameterName);
            }
        }

        public static void NotEmpty(string value, string parameterName, bool isWhitespaceConsideredEmpty = false)
        {
            if (isWhitespaceConsideredEmpty ? string.IsNullOrWhiteSpace(value) : string.IsNullOrEmpty(value))
            {
                RaiseArgumentEmptyException(parameterName);
            }
        }

        public static void NotEmpty(string value, string parameterName)
        {
            NotEmpty(value, parameterName, false);
        }

        public static void NotEmpty<T>(T value, string parameterName)
        {
            if (value == null)
            {
                RaiseArgumentEmptyException(parameterName);
            }
        }

        private static void RaiseArgumentEmptyException(string parameterName)
        {
            throw new ArgumentException("The given argument is null or empty", parameterName);
        }
    }
}
